<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CouponsController
 *
 * @author Admin
 */
class Back_CouponsController extends Zend_Controller_Action
{
    public function init() {
        $this->_helper->layout->setLayout('admin');
    }
    public function indexAction() {
        
    }
    
    public function couponsAction() {
        $obj = new Back_Model_Coupons();
        $coupons = $obj->getAllCoupons();
        
        //подсчитываем все коды
        $allCode = $obj->getCountAllCode();
        //подсчитываем активированые коды
        $activatedCode = $obj->getCountStatusCode(1);
        //подсчитываем не ативированные коды
        $notActivatedCode = $obj->getCountStatusCode(2);
        //подсчитываем заблокированные коды
        $blockedCode = $obj->getCountStatusCode(3);
        if (!empty($coupons)){
        foreach ($coupons as $key => $value) {
            $allSeriesCode = $obj->getCountSeriesCode($value['id']);
            $coupons[$key]['all_series_code'] = count($allSeriesCode);
            
            $allActivatedSeriesCode = $obj->getCountSeriesStatusCode($value['id'], 1);
            $coupons[$key]['all_activated_series_code'] = count($allActivatedSeriesCode);
        }
        }
        $this->view->activated = $activatedCode;
        $this->view->notactivated = $notActivatedCode;
        $this->view->blocked = $blockedCode;
        $this->view->allcode = $allCode;
        $this->view->coupons = $coupons;
        
    }
}

?>
